#include "deviceinformation.h"
#include "ui_deviceinformation.h"
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavdevice/avdevice.h>
#include "libswscale/swscale.h"
#include "libavutil/imgutils.h"
#include <libavformat/avio.h>
#include <libavutil/file.h>
#include <SDL/SDL.h>
}
using namespace std;
DeviceInformation::DeviceInformation(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DeviceInformation)
{
    ui->setupUi(this);
    showDeviceInfo();
}

DeviceInformation::~DeviceInformation()
{
    delete ui;
}

void DeviceInformation::showDeviceInfo() {
    AVFormatContext *pFormatCtx = avformat_alloc_context();
    AVDictionary    *options = nullptr;

    av_dict_set(&options, "list_devices", "true", 0);
    AVInputFormat *iformat = av_find_input_format("dshow");


    string result =
        to_string(avformat_open_input(&pFormatCtx, "video=dummy", iformat,
                                      &options));
    QString info;
    info =
        QString::fromStdString(("========Device Info=============\n open cam" +
                                result + "================================\n"));
    ui->plainTextEditDeviceInfo->setPlainText(info);
}
